//
//  MovieTableViewCell.m
//  豆瓣
//
//  Created by dllo on 15/12/9.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface MovieTableViewCell ()
@property (nonatomic, retain) UIImageView *headImageView;
@property (nonatomic, retain) UILabel *nameLabel;


@end

@implementation MovieTableViewCell

- (void)dealloc{
    [_nameLabel release];
    [_headImageView release];
    [_movie release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)setMovie:(Movie *)movie{
    if (_movie != movie) {
        [_movie release];
        _movie = [movie retain];
    }
    self.nameLabel.text = self.movie.movieName;
//    NSLog(@"!~~~%@", self.nameLabel.text);
    NSURL *url = [NSURL URLWithString:self.movie.pic_url];
//    NSData *data = [NSData dataWithContentsOfURL:url];
//    self.headImageView.image = [UIImage imageWithData:data];
    [self.headImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picholder"]];
}

- (void)createSubviews{
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_eventlistcell"]];
    imageView.frame = CGRectMake(10, 15, 355, 140);
    [self.contentView addSubview:imageView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 50, 200, 50)];
    self.nameLabel.textColor = [UIColor blackColor];
    self.nameLabel.text = @"暂无";
    [imageView addSubview:_nameLabel];
    [_nameLabel release];
    
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, 80, 120)];
    self.headImageView.backgroundColor = [UIColor yellowColor];
    [imageView addSubview:_headImageView];
    [_headImageView release];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
